package com.smec.moblie.util;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.view.Display;

import com.smec.moblie.R;

public class URLDrawable extends BitmapDrawable {
	protected Drawable drawable;

	@SuppressWarnings("deprecation")
	public URLDrawable(Context context) {
		this.setBounds(getDefaultImageBounds(context));
		drawable = context.getResources().getDrawable(R.mipmap.photo);
		drawable.setBounds(getDefaultImageBounds(context));
	}

	@Override
	public void draw(Canvas canvas) {
		if (drawable != null) {
			drawable.draw(canvas);
		}
	}

	@SuppressWarnings("deprecation")
	public Rect getDefaultImageBounds(Context context) {
		Display display = ((Activity) context).getWindowManager().getDefaultDisplay();
		int width = display.getWidth() / 3;
//		int height = (int) (width * 9 / 16);
		int height = width;
		Rect bounds = new Rect(0, 0, width, height);
		return bounds;
	}
}